﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Paddle : Object_Basic
{
    public float Add_Speed;
    public float Max_Speed;
    public float Min_Speed;
    delegate void change_speed();
    change_speed change;
    void Add()
    {
        Speed += Add_Speed;
    }
    void subtract()
    {
        Speed -= Add_Speed;
    }
    public float Speed=1;
    protected override void Start()
    {
        base.Start();
        change = new change_speed(Add);
    }
    protected void FixedUpdate()
    {
        if (Speed >= Max_Speed)
        {
            change = new change_speed(subtract);
        }
        if (Speed <= Min_Speed)
        {
            change = new change_speed(Add);
        }
        if (Paddle_G.reward_count > Ball_G.Presented)
        {
            Paddle_G.reward_count--;
            Remove(FatherObject);
        }
        change();
        float RotateSpeed = Input.GetAxis("Horizontal");
        Vector3 degree = new Vector3(0, 0, RotateSpeed * Speed);
        FatherObject.transform.Rotate(degree);
    }

    //void Rotate(float RotateSpeed)
    //{
        
    //}
}
